<?php
namespace Admin\Controller;
use Admin\Controller\BaseController;
class AdminsController extends BaseController {
	private $tbl;
	public function _initialize(){
		$this->tbl='admins';
		$this->model=D($this->tbl);
		parent::_initialize();
	}
	public function mod(){//修改界面
		$this->display();
	}
	public function update(){//修改
		$data=I("post.");
		//var_dump($data);
		$position="Users/index";
		//var_dump($data['yyjl_password']);
		if(md5($data['yyjl_password'])!=$_SESSION['admin']['yjl_password']){//如果密码验证正确
			// var_dump(md5($data['yyjl_password']));
			// var_dump($_SESSION['admin']['yjl_password']);
			// exit;
			$this->error("更新失败！",U($position));
		}	
		if($data['yjl_password']==null){
			$data['yjl_password']=$_SESSION['admin']['yjl_password'];
		}		
		$newdata=array(
			"yjl_adminname"=>$data['yjl_adminname'],
			"yjl_password"=>$data['yjl_password'],
			"yjl_id"=>$_SESSION['admin']['yjl_id']
		);
		$user=$this->model->create($newdata);
			$position="mod";
			if($user){
				$this->model->save();
				$_SESSION['admin']=$newdata;
				$this->success('更新成功！',U($position));
			}else{
				$this->error("更新失败！",U($position));
			}
	}	
}